﻿using Ndns.HostsFile;
using Ndns.ServerHost.Abstractions;
using System;

namespace Ndns.ServerHost.Builder
{
    public static class HostsFileMiddlewareBuilder
    {

        public static IMiddlewaresBuilder UseHostsFile(this IMiddlewaresBuilder builder, string path)
        {
            return UseHostsFile(builder, path, new HostsFileMiddlewareOptions());
        }
             
        public static IMiddlewaresBuilder UseHostsFile(this IMiddlewaresBuilder builder, string path, HostsFileMiddlewareOptions options)
        {
            if (builder == null)
                throw new ArgumentNullException(nameof(builder));
            if (path == null)
                throw new ArgumentNullException(nameof(path));
            if (options == null)
                throw new ArgumentNullException(nameof(options));

            builder.Use(new HostsFileMiddleware(path, options));

            return builder;
        }
    }
}
